
;detect on what type of c= the game is running
 ;bit 0 - AR        use extra mem for buffering menu
;bit 1 - RR        use extra mem for buffering menu
;bit 2 - REU       if REU detected -> we will use the REU for scrolling
 ;bit 3 - SCPU      if SCPU detected, all illegal ops have to be replaced with legal ops..
 ;bit 4 - 128       turn on 2mhz in borders, use VDC for buffering
;bit 5 - EMULATOR  (important for choosing what keys to use!)
;bit 6 - reserved  (16/64K VDC?)
 ;bit 7 - PAL/NTSC  NTSC sucks.. but whatever ;)

detectmodel

         lda #0
         sta computermodel

;------------
;detect 128 -
;------------

	lda #$cc
	sta $d030
	lda $d030
	cmp #$fc
	bne *+8
	lda computermodel
	ora #%00010000
	sta computermodel

;-------------
;detect NTSC -
;-------------

	lda $d011
	bmi *-3
	lda $d011
	bpl *-3
detectloop
	lda $d012
	cmp $d012
	beq *-3
	cmp #$37
	beq onlypal
	lda $d011
	bmi detectloop

	lda computermodel
	ora #%10000000
	sta computermodel
onlypal

;------------
;detect REU -
;------------

;----------------
;detect AR & RR -
;----------------

	;sei

	;ldy $01
	;lda #$37
	;sta $01

	;ldx $8000     ;get byte from $8000
	;lda #$20      ;turn on AR ram @ $8000, if it exists..
	;sta $de00
	;inx           ;put the byte+1 back @ $8000
	;stx $8000
	;lda #$0a      ;turn off AR ram
	;sta $de00
	;cpx $8000     ;compare the byte we've just written to $8000
	;beq noar      ;if it's the same, there was no extra RAM! (and no AR :()

	;temp code
	;lda computermodel
	;ora #1
	;sta computermodel
	;temp code

	;;if we've gotten here, AR or RR is present!!
	;
	;dex
	;stx $8000
	;lda #$2b      ;try to switch to ram bank 1
	;sta $de00
	;inx
	;inx
	;stx $8000
	;lda #$23      ;switch back to bank 0
	;sta $de00
	;cpx $8000     ;compare the byte
	;beq norr      ;if it's the same, no extra bank was present...
	;
	;;if we gotten here, RR is present
	;
	;lda #$0a
	;sta $de00
	;
	;lda computermodel
	;ora #%00000010
	;sta computermodel
	;bne endarrr
norr     ;
	;;if we've gotten here, AR is present!!
	;
	;lda #$0a
	;sta $de00
	;
	;lda computermodel
	;ora #%00000001
	;sta computermodel
	;bne endarrr
noar
         ;dex           ;put original byte back
         ;stx $8000
         
         ;sty $01
endarrr
	;cli

;-------------
;detect SCPU -
;-------------

	lda $d0bc
	asl
	bcs noscpu
	;doublecheck... (checks for 65816 present..)
	sei
	sed
	lda #$99
	clc
	adc #$01
	bmi noscpu2
	cld

	lda computermodel
	ora #%00001000
	sta computermodel
noscpu2
      	cld
	cli
noscpu

;------------
;detect EMU -
;------------

;-------------------
;detect 16/64K VDC -
;-------------------

         rts

;--------------------------------------------------------------------------------------------------------------------

